<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>学生管理</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<jsp:include page="menu.jsp"/>
<div class="index-content">
    <div class="index-content-operation">
        <a class="info-detail">学生管理</a>
        <br>
        <br>
    </div>
    <br>
    <div class="index-content-operation">
        <c:if test="${loginUser.userType == '辅导员'}">
            <button class="btn btn-pill btn-line btn-success btn-sm"
                    onclick="window.location.href='student_add.jsp'">添加
            </button>
        </c:if>
        <div class="index-content-operation-search"><input id="search_keyword" placeholder="学生姓名" type="text"
                                                           name="search_keyword"/><input type="hidden" id="searchColumn"
                                                                                         name="searchColumn"
                                                                                         value="studentName"/>
            <button class="btn btn-pill btn-line btn-primary btn-sm" onclick="searchList()">搜索</button>
        </div>
    </div>
    <br>

    <table class="table table-striped table-hover table-bordered">
        <thead>
        <tr class="index-content-table-th">
            <th>姓名</th>
            <th>学号</th>
            <th>班号</th>
            <th>性别</th>
            <th>通讯地址</th>
            <th>学生电话</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${list}" var="vo">
            <tr class="index-content-table-td">
                    <%--                实体类的属性--%>
                <td>${vo.studentName}</td>
                <td>${vo.id}</td>
                <td>${vo.classId}</td>
                <td>${vo.sex}</td>
                <td>${vo.address}</td>
                <td>${vo.telephone}</td>
                <td>
                    <button class="btn btn-pill btn-line btn-success btn-sm" style="padding: 0px 1px;"
                            onclick="window.location.href='StudentServlet?action=get&id=${vo.id}'">详情
                    </button>&nbsp;
                    <c:if test="${loginUser.userType == '辅导员'}">
                        <button class="btn btn-pill btn-line btn-danger btn-sm" style="padding: 0px 1px;"
                                onclick="window.location.href='StudentServlet?action=editPre&id=${vo.id}'">编辑
                        </button>
                        &nbsp;
                        <button class="btn btn-pill btn-line btn-default btn-sm" style="padding: 0px 1px;"
                                onclick="if(window.confirm('将要删除：${vo.studentName}？'))window.location.href='StudentServlet?action=delete&id=${vo.id}'">
                            删除
                        </button>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div style="float: right;padding-right: 10px;color: #515151;">
        <jsp:include page="split.jsp"/>
    </div>
</div>
</body>
<script>
    function searchList() {
        window.location.href = "StudentServlet?action=list&searchColumn=" + document.getElementById("searchColumn").value + "&keyword=" + document.getElementById("search_keyword").value;
    }
</script>
</html>
